<!DOCTYPE html>
<html lang="en">
<!-- 维修员历史维修任务页面 -->
<?php
// 判断是否正常访问
session_start();
if (!isset($_SESSION['REPAIRER'])) {
    echo "<script>alert('非法访问！请先登录！');window.location.href='../../../index.html';</script>";
    die();
}
?>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>校园报修系统 · 维修员</title>
    <link rel="stylesheet" href="../bootstrap-5.3.3-dist/bootstrap.min.css">
    <script src="../bootstrap-5.3.3-dist/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/r-public.css">
    <link rel="stylesheet" href="css/r-history.css">
    <script src="js/r-history.js"></script>
</head>

<body>
    <nav class="navbar fixed-top navbar-expand-lg bg-body-tertiary navbar-style">
        <div class="container-fluid">
            <a class="navbar-brand" href="javascript:;">校园报修系统</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText"
                aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarText">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0">
                    <li class="nav-item">
                        <a class="nav-link" href="r-main.php">待维修任务</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" aria-current="page" href="r-history.php">历史维修任务</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="r-info.php">我的信息</a>
                    </li>
                </ul>
                <span class="navbar-text">
                    当前登录：<?php echo $_SESSION['REPAIRER']['r_name'];?>
                </span>
                <span class="navbar-text logout-btn">
                    <a href="php/logout.php">
                        <button class="btn btn-danger">退出登录</button>
                    </a>
                </span>
            </div>
        </div>
    </nav>
    <main>
        <div class="content">
            <?php include_once("php/get-fix-history.php")?>
            <h4>我的维修历史任务<span class="total-num"><?php echo $num;?></span></h4>
            <div class="top-search">
                <form class="row g-3">
                    <div class="col-auto">
                        <input type="text" class="form-control" id="fix_id" placeholder="输入检索单号查询">
                    </div>
                    <div class="col-auto">
                        <button type="button" class="btn btn-primary mb-3" onclick="return searchHistory();">查询</button>
                    </div>
                </form>
            </div>
            <div class="task-list">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th scope="col">报修ID</th>
                            <th scope="col">报修人</th>
                            <th scope="col">报修时间</th>
                            <th scope="col">联系电话</th>
                            <th scope="col">故障地点</th>
                            <th scope="col">故障类型</th>
                            <th scope="col">派单时间</th>
                            <th scope="col">完成时间</th>
                            <th scope="col">详情</th>
                        </tr>
                    </thead>
                    <tbody id="show-info-div">
                        <?php 
                            show_history();
                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </main>
    <footer>
        校园报修系统 · 维修员 © 2025 All rights reserved.
    </footer>
</body>

</html>